<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>后台管理界面</title>
	<link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../jquery.min.js"></script>
	<script type="text/javascript" src="../jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../extend.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            initProfile();
            initModules();
            setInterval(initProfile,30000);
		});
	    function TabClosing(title, index) {
	        var target = this;
	        $.messager.confirm('提示', '确定关闭页面[' + title + "]？", function (r) {
	            if (r) {
	                var opts = $(target).tabs('options');
	                var bc = opts.onBeforeClose;
	                opts.onBeforeClose = function () { };  // allowed to close now
	                $(target).tabs('close', index);
	                opts.onBeforeClose = bc;  // restore the event function
	            }
	        });
	        return false;	// prevent from closing
	    }
        function initProfile(){
            $.get("../../api/user/whoami",function(response){
                if(response.Result==0){
                    var profile = JSON.parse(response.Data);
                    var info = "当前登录身份:"+profile.SiteName+"/"+profile.Department+"/"+profile.UserName;
                    info += "   <a href='../logout.html'>注销>></a>";
                    $("#profile").html(info);
                }else{
                    $.messager.alert("错误","登录超时","error");
                    window.location = "../login.html";
                }
            },"json")
            .error(function(){
                $.messager.alert("错误","系统内部错误","error");
                window.location = "../login.html";
            })
        }
        function initModules(){
            $.get("../../api/modules/listadmin",function(response){
                if(response.Result==0){
                    var modules = JSON.parse(response.Data);
                    $("#menu").tree("loadData",modules);
                }else{
                    $.messager.alert("错误",response.Message,"error");
                }
            },"json")
            .error(function(){
                $.messager.alert("错误","系统内部错误","error");
            })
        }
    </script>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',border:false" style="height:60px;background:#B3DFDA;padding:5px">
        <img src="../image/logo.png" height="47px"></img>
        <div style="float:right;padding:5px;color:#0E2D5F"><b id="profile"></b></div>
    </div>
	<div data-options="region:'west',split:true,title:'功能菜单'" style="width:150px;padding:3px;">
		<ul class="easyui-tree" id="menu" data-options="
					animate:true,
					formatter:function(node){
						var s = node.Name;
						return s;
					},
                    onClick:function(node){
                        addTab(node.AutoId,node.Name,node.AppUrl);
                    }
				"></ul>
    </div>
	<div data-options="region:'south',border:false" style="text-align:center;height:25px;background:#A9FACD;padding:0px;margin:0px;font-size:8px">
         <p style="margin-top:3px;margin-bottom:3px">技术支持：李伟权 Tel:13672917587 Email:liweiquande@163.com</p>
    </div>
	<div data-options="region:'center'">
        <div id="mainFrame"  class="easyui-tabs" data-options="
                onBeforeClose:TabClosing,
                fit:true,
                border:false,
                tabHeight:30,
            ">
        </div>
    </div>
</body>
</html>